package cn.edu.glut.dto;

import javax.validation.constraints.NotNull;

import org.springframework.beans.BeanUtils;

import cn.edu.glut.entity.Major;
import cn.edu.glut.entity.Secretary;
import cn.edu.glut.utils.ValidValue;
import lombok.Data;

@Data
public class SecretaryInputDTO implements DTOConvert<Secretary> {
	private String id;			//id
	@NotNull(message = "专业不能为空")
	private String majorId;		//专业
	@NotNull(message = ValidValue.Valid_MSG.USERNAME_NOT_NULL)
	private String username;	//学号
	@NotNull(message = ValidValue.Valid_MSG.PASSWORD_NOT_NULL)
	private String password;	//密码
	@NotNull(message = ValidValue.Valid_MSG.NAME_NOT_NULL)
	private String nickname;	//名字
	
	@Override
	public Secretary convertToEntity() {
		Secretary s = new Secretary();
		BeanUtils.copyProperties(this, s);
		Major m = new Major(majorId);
		s.setMajor(m);
		return s;
	}
}
